<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button class="set">存储数据</button>
    <button class="get">获取数据</button>
    <script>
        const person={
            name:"陶品奇",
            hobby:"前端",
            age:22,
            address:"湖南省衡阳市"
        }
        document.querySelector(".set").addEventListener("click", function () {
            //存储数据：localStorage.setItem(key,value)
            localStorage.setItem("person", JSON.stringify(person))

        })

        document.querySelector(".get").addEventListener("click", function () {
            //获取数据：localStorage.getItem(key)
            const person = JSON.parse(localStorage.getItem("person"))            
            console.log(person);

        })
    </script>
</body>

</html>